package com.g8.pethospitallearnbackend.mapper;

import com.g8.pethospitallearnbackend.entity.Flow;
import com.g8.pethospitallearnbackend.entity.FlowExample;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

@Mapper
public interface FlowMapper {
    @SelectProvider(type=FlowSqlProvider.class, method="countByExample")
    long countByExample(FlowExample example);

    @DeleteProvider(type=FlowSqlProvider.class, method="deleteByExample")
    int deleteByExample(FlowExample example);

    @Delete({
        "delete from flow",
        "where flow_id = #{flowId,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String flowId);

    @Insert({
        "insert into flow (flow_id, role_id, ",
        "flow_name, flow_order, ",
        "flow_visible)",
        "values (#{flowId,jdbcType=VARCHAR}, #{roleId,jdbcType=VARCHAR}, ",
        "#{flowName,jdbcType=VARCHAR}, #{flowOrder,jdbcType=INTEGER}, ",
        "#{flowVisible,jdbcType=TINYINT})"
    })
    int insert(Flow record);

    @InsertProvider(type=FlowSqlProvider.class, method="insertSelective")
    int insertSelective(Flow record);

    @SelectProvider(type=FlowSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="flow_id", property="flowId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="role_id", property="roleId", jdbcType=JdbcType.VARCHAR),
        @Result(column="flow_name", property="flowName", jdbcType=JdbcType.VARCHAR),
        @Result(column="flow_order", property="flowOrder", jdbcType=JdbcType.INTEGER),
        @Result(column="flow_visible", property="flowVisible", jdbcType=JdbcType.TINYINT)
    })
    List<Flow> selectByExample(FlowExample example);

    @Select({
        "select",
        "flow_id, role_id, flow_name, flow_order, flow_visible",
        "from flow",
        "where flow_id = #{flowId,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="flow_id", property="flowId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="role_id", property="roleId", jdbcType=JdbcType.VARCHAR),
        @Result(column="flow_name", property="flowName", jdbcType=JdbcType.VARCHAR),
        @Result(column="flow_order", property="flowOrder", jdbcType=JdbcType.INTEGER),
        @Result(column="flow_visible", property="flowVisible", jdbcType=JdbcType.TINYINT)
    })
    Flow selectByPrimaryKey(String flowId);

    @UpdateProvider(type=FlowSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Flow record, @Param("example") FlowExample example);

    @UpdateProvider(type=FlowSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Flow record, @Param("example") FlowExample example);

    @UpdateProvider(type=FlowSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Flow record);

    @Update({
        "update flow",
        "set role_id = #{roleId,jdbcType=VARCHAR},",
          "flow_name = #{flowName,jdbcType=VARCHAR},",
          "flow_order = #{flowOrder,jdbcType=INTEGER},",
          "flow_visible = #{flowVisible,jdbcType=TINYINT}",
        "where flow_id = #{flowId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(Flow record);

}